/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.core.logisoft.db;

import com.core.logisoft.db.domain.Quotation;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

/**
 * 
 * @author Administrator
 */
public class DB {

    private static List<Quotation> quatationList = null;

    public static void main(String[] args) throws Exception {
        quatationList = new ArrayList<Quotation>();
        ResultSet rs = getResultSet("quotation");
        while (rs.next()) {
            quatationList.add(new Quotation(rs));
            new Quotation(rs).save();
        }
        rs.close();
        //rs = getResultSet("booking_fcl","file_no");
    }


    private static ResultSet getResultSet(String table, String... conditions) throws SQLException{
        StringBuffer query = new StringBuffer("select * from ");
        query.append(table);

        if(conditions != null && conditions.length > 0){
            query.append(" WHERE null is null ");
            for(String cond : conditions){
                query.append(" AND ");
                query.append(cond);
            }
        }
        Connection con = DBConnection.getConnection();
        Statement st = con.createStatement();
        ResultSet rs = st.executeQuery(query.toString());
        return rs;

    }
}
